package com.timesheet.gui.tasktracker.composites;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class TaskTrackerSectionsComposite extends Composite {

	private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());

	private TaskTrackerSaveResultComposite taskTrackerSaveResultComposite;

	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public TaskTrackerSectionsComposite(Composite parent, int style) {
		super(parent, style);
		addDisposeListener(new DisposeListener() {

			public void widgetDisposed(DisposeEvent e) {
				toolkit.dispose();
			}
		});
		toolkit.adapt(this);
		toolkit.paintBordersFor(this);
		setLayout(new GridLayout(1, false));

		Section sctnCreateTaskTracker = toolkit.createSection(this, Section.TWISTIE | Section.TITLE_BAR);
		sctnCreateTaskTracker.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		toolkit.paintBordersFor(sctnCreateTaskTracker);
		sctnCreateTaskTracker.setText("Create TaskTracker");
		sctnCreateTaskTracker.setExpanded(true);

		TaskTrackerHistotyComposite taskTrackerHistotyComposite =
				new TaskTrackerHistotyComposite(sctnCreateTaskTracker, SWT.NONE);
		toolkit.adapt(taskTrackerHistotyComposite);
		toolkit.paintBordersFor(taskTrackerHistotyComposite);
		sctnCreateTaskTracker.setClient(taskTrackerHistotyComposite);

		Section sctnSaveResult = toolkit.createSection(this, Section.TWISTIE | Section.TITLE_BAR);
		sctnSaveResult.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		toolkit.paintBordersFor(sctnSaveResult);
		sctnSaveResult.setText("Saved Task Tracker");

		taskTrackerSaveResultComposite = new TaskTrackerSaveResultComposite(this, SWT.NONE);
		taskTrackerSaveResultComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		toolkit.adapt(taskTrackerSaveResultComposite);
		toolkit.paintBordersFor(taskTrackerSaveResultComposite);

	}

	public TaskTrackerSaveResultComposite getTaskTrackerSaveResultComposite() {
		return taskTrackerSaveResultComposite;
	}

}
